<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
         <meta charset="UTF-8">
         <title>Document</title>
         <script type="text/javascript">
                //水仙花数
                 for (var num = 100; num <= 999; num++) {

                           var str = num.toString();
                            var res1 =Number(str.slice(0,1)) //百位   或者用charAt(0)
                           var res2 =Number(str.slice(1,2)) //十位        或者用charAt(1)
                         var res3 =Number(str.slice(2,3)) //个位        或者用charAt(2)

                         var sumcube = Math.pow(res1,3)+Math.pow(res2,3)+Math.pow(res3,3); //立方和
                           num = res1*100+res2*10+res3; //这个数
                         if(sumcube == num){
                                    console.log(num);
                             alert(num);
                                }
                    }

        </script>
     </head>
 <body>

 </body>
</html>